using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace sql_train
{
    public class SimpleDataRow
    {
        public SimpleDataRow(List<object> mData, ReadOnlyCollection<SimpleDataColumn> mColumns)
        {
            m_data = mData;
            m_columns = mColumns;
        }

        public bool Equals(SimpleDataRow other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Utils.CollectionsEqual(other.m_data, m_data) && Utils.CollectionsEqual(other.m_columns, m_columns);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (SimpleDataRow)) return false;
            return Equals((SimpleDataRow) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return (Utils.GetCollectionHashCode(m_data)*397) ^ Utils.GetCollectionHashCode(m_columns);
            }
        }

        private readonly List<object> m_data;
        public object this [int i]
        {
            get { return m_data[i]; }
        }

        private readonly ReadOnlyCollection<SimpleDataColumn> m_columns;
        public ReadOnlyCollection<SimpleDataColumn> Columns
        {
            get { return m_columns; }
        }
    }
}